<template>
  <div class="bg-white rounded-lg p-5 h-full flex flex-col">
    <div class="font-bold text-xl mb-4">查看整改材料</div>
    <el-descriptions :column="2" border>
      <el-descriptions-item label="医疗机构名称">
        {{ $route.query.name }}
      </el-descriptions-item>
      <el-descriptions-item label="机构代码">
        {{ $route.query.creditCode }}
      </el-descriptions-item>
      <el-descriptions-item label="整改意见书">
        <div v-for="(item, index) in dataList" class="mb-2" :key="index">
          <el-link type="primary">
            <span>{{ item.fileName }}</span>
            <span>{{ item.fileUrl }}</span>
          </el-link>
        </div>
      </el-descriptions-item>
    </el-descriptions>
    <hr class="my-4" />
    <div>
      <el-button type="primary" @click="goBack">返回 </el-button>
      <template v-if="status == 1">
        <el-button type="primary" @click="submit(1)">整改通过</el-button>
        <el-button type="error" @click="submit(0)">整改驳回</el-button>
      </template>
    </div>
  </div>
</template>

<script>
import {
  setCorrectionPassAPI,
  setCorrectionRejectAPI,
  getCorrectionInfoAPI,
} from "@/api/zhangping/health-care/doctor-prescribe";
export default {
  name: "",
  mixins: [],
  components: {},
  props: {},
  data() {
    return {
      dataList: [],
      status:null 
    };
  },
  computed: {
    
  },
  watch: {},
  created() {},
  mounted() {
    this.getInfo();
  },
  methods: {
    getInfo() {
      getCorrectionInfoAPI({
        abnormalPrescriptionId: this.$route.query.id,
      }).then((res) => {
        if (res.code === 200) {
          this.dataList = res.data.fileList;
          this.status = res.data.correctionStatus
        }
      });
    },
    goBack() {
      this.$router.go(-1);
    },
    submit(status) {
      const api = status === 1 ? setCorrectionPassAPI : setCorrectionRejectAPI;
      api({ abnormalPrescriptionId: this.$route.query.id }).then((res) => {
        this.$message.success("操作成功");
        this.goBack();
      });
    },
  },
};
</script>

<style scoped lang="scss"></style>
